package com.todolist.mapper;

import com.todolist.dao.TTodolist;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TTodolistMapper {

    /**
     * 根据用户名代办列表
     * @param username
     * @return
     */
    @Select("select * from t_todolist where username = #{username}")
    List<TTodolist> getByUsername(String username);

    @Update("UPDATE t_todolist SET todoStatus = #{todoStatus} WHERE id = #{id}")
    void setStatusByID (TTodolist todolist);

    @Delete("DELETE FROM t_todolist WHERE id = #{id} ")
    void deleteToDoById(int id);

    @Delete("DELETE FROM t_todolist WHERE username = #{username} and todoStatus = 1")
    void deleteDoByusername(String username);

}
